package disjunction.examples.basics
{
	import disjunction.View;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	
	/**
	 * @author Nick Wiggill
	 */
	
	public class DemoView extends View
	{
		private var _sprite:Shape;
		
		protected override function update(timeDeltaMs:uint):void
		{
			_sprite.x = model.position.x;
			_sprite.y = model.position.y;
		}

		public override function initialise(userData:Object):void
		{
			_sprite = new Shape();
			
			//face
			_sprite.graphics.beginFill(0xFFFF00);
			_sprite.graphics.drawCircle(0, 0, model.radius);
			_sprite.graphics.endFill();

			//left eye
			_sprite.graphics.beginFill(0x000000);
			_sprite.graphics.drawCircle(-2.5, -2.5, 1);
			_sprite.graphics.endFill();
			
			//right eye
			_sprite.graphics.beginFill(0x000000);
			_sprite.graphics.drawCircle(2.5, -2.5, 1);
			_sprite.graphics.endFill();
			
			//mouth
			_sprite.graphics.beginFill(0x000000);
			_sprite.graphics.lineStyle(1);
			_sprite.graphics.moveTo(0, 3);
			_sprite.graphics.lineTo(-3, 2);
			_sprite.graphics.lineTo(3, 2);
			_sprite.graphics.endFill();
			
			(context as DisplayObjectContainer).addChild(_sprite);
		}
	}
}